{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter 3"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Our first TensorFlow graph"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "outs = 5\n"
     ]
    }
   ],
   "source": [
    "import tensorflow as tf \n",
    "a = tf.constant(5) \n",
    "b = tf.constant(2)\n",
    "c = tf.constant(3)\n",
    "d = tf.multiply(a,b) \n",
    "e = tf.add(c,b) \n",
    "f = tf.subtract(d,e) \n",
    "sess = tf.Session() \n",
    "outs = sess.run(f) \n",
    "sess.close() \n",
    "print(\"outs = {}\".format(outs))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Constructing and managing our graph "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<tensorflow.python.framework.ops.Graph object at 0x7fbb8c792f50>\n",
      "<tensorflow.python.framework.ops.Graph object at 0x7fbb8c7926d0>\n"
     ]
    }
   ],
   "source": [
    "import tensorflow as tf\n",
    "print(tf.get_default_graph())\n",
    "\n",
    "g = tf.Graph()\n",
    "print(g)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "False\n",
      "True\n"
     ]
    }
   ],
   "source": [
    "a = tf.constant(5) \n",
    "\n",
    "print(a.graph is g)\n",
    "print(a.graph is tf.get_default_graph())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "True\n",
      "False\n",
      "True\n"
     ]
    }
   ],
   "source": [
    "g1 = tf.get_default_graph() \n",
    "g2 = tf.Graph() \n",
    "\n",
    "print(g1 is tf.get_default_graph())\n",
    "\n",
    "with g2.as_default(): \n",
    "    print(g1 is tf.get_default_graph())\n",
    "\n",
    "print(g1 is tf.get_default_graph())"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Fetches "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "outs = [5, 2, 3, 10, 5, 5]\n",
      "<type 'numpy.int32'>\n"
     ]
    }
   ],
   "source": [
    "with tf.Session() as sess:\n",
    "   fetches = [a,b,c,d,e,f]\n",
    "   outs = sess.run(fetches) \n",
    "\n",
    "print(\"outs = {}\".format(outs))\n",
    "print(type(outs[0]))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Nodes are operations, edges are Tensor objects  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Tensor(\"Const_4:0\", shape=(), dtype=float32)\n"
     ]
    }
   ],
   "source": [
    "c = tf.constant(4.0)\n",
    "print(c)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Data types  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Tensor(\"Const_5:0\", shape=(), dtype=float64)\n",
      "<dtype: 'float64'>\n"
     ]
    }
   ],
   "source": [
    "c = tf.constant(4.0, dtype=tf.float64)\n",
    "print(c)\n",
    "print(c.dtype)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<dtype: 'float32'>\n",
      "<dtype: 'int64'>\n"
     ]
    }
   ],
   "source": [
    "x = tf.constant([1,2,3],name='x',dtype=tf.float32) \n",
    "print(x.dtype)\n",
    "x = tf.cast(x,tf.int64)\n",
    "print(x.dtype)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Tensor arrays and Shapes  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Python List input: (2, 3)\n",
      "3d Numpy array input: (2, 2, 3)\n"
     ]
    }
   ],
   "source": [
    "import numpy as np \n",
    "\n",
    "c = tf.constant([[1,2,3],\n",
    "                 [4,5,6]]) \n",
    "print(\"Python List input: {}\".format(c.get_shape()))\n",
    "\n",
    "c = tf.constant(np.array([\n",
    "                 [[1,2,3], \n",
    "                  [4,5,6]], \n",
    "\n",
    "                 [[1,1,1], \n",
    "                  [2,2,2]]\n",
    "                 ])) \n",
    "\n",
    "print(\"3d Numpy array input: {}\".format(c.get_shape()))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(1, 50000)\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAABDAAAAFOCAYAAABwhO0AAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzs3XmYHGW5sPH7IawBwiabBISIC4uIigIKJiCgiAgiCAoo\nHo9RlO3ghwICBlwARUEExRxUFhVEFgWFEIKHTUCIx+WwBFHWsEkgC5CwJc/3R1VPOp2eradnuid9\n/66rrumqeuutp6Yyle6n3yUyE0mSJEmSpHa2VKsDkCRJkiRJ6o0JDEmSJEmS1PZMYEiSJEmSpLZn\nAkOSJEmSJLU9ExiSJEmSJKntmcCQJEmSJEltzwSGJGmJFBEbRkSWy3lNqvOhsr6HmlFfL+eqxH5D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144428973v5bbbbmP06NFDGaYktZW//OUvHHfccVx99dV19z/77LM8++yz3H///Vx2\n2WV8+ctfZvvtt+fEE09k3LhxTY3FBIYkDWOTJk3iySefBGCzzTZjzpw5PProo9x///388Y9/5D3v\neU+LI5Sk9rH22mszadKkbvc/8MADHHXUUVx++eUATJ8+nSOOOIJLL710qEKUpLZy2mmn8ZWvfIUF\nCxYssn311Vdn9OjRrLHGGsyePZsnn3ySxx9/HIDM5KabbmKHHXbg1FNP5ctf/nLT4nEMDGkYclwM\nVVR3H/nkJz/J/vvvX3efJKl3Y8aM4de//jU77rhj17bf/OY3PPPMMy2MSpJa49BDD+Woo47qSl4s\nu+yyHH744UydOpUZM2bwt7/9jT/84Q/8+c9/5rHHHuOBBx7g+9//Pq9//eu76qgkNZrFBIbUAiYg\n1AzPPvssV111FQBLLbUUn/jEJzjggAO69l9yySXMmzevVeFJ0rC01FJLcdhhh3Wtz58/n6lTp7Yw\nIkkaeueeey5nnXVW1/ob3/hG7r77bs444wze8Y53EBGLHbPRRhtx2GGHce+993LWWWcxcuTIpsdl\nAkOShqmLLrqIl19+GYBx48YxevRoNttsM972trcBMGfOHK644opWhihJw9Kb3/zmRdZtgSGpk/zr\nX/9aJJE7ZswYbrnlFjbeeOM+Hb/MMsvwxS9+kdtuu22R1hjNYAJDkoap6i4iBx54YN3XdiORpP6r\nJIcrVlpppRZFIklD7zvf+U5XK96lllqK8847jzXXXLPf9WyxxRYceuihTY3NBIYkDUN33313V5Pm\nFVZYgY9+9KNd+z7+8Y8zYsQIAK6//nqmT5/ekhglabi6/fbbF1nffPPNWxSJJA2tGTNmcP7553et\n77rrrmy//fYtjGhRJjAkaRiqblmxxx57sPLKK3etr7POOuy0004ALFiwgAsuuGCow5OkYeuZZ57h\nlFNO6VrfZpttGDNmTAsjkqShM3nyZF588cWu9c9+9rMtjGZxTqMqDaHBGLSzXp3jxzf/PGof8+fP\n5+c//3nXenWXkept1157LQDnn38+xx577JDFJ0nDzUsvvcT06dOZMmU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jKHUvdvHt+xk3tMAqup3SY4CPgocD3yqPX5/ko3Ah6vq\n12OoU9IKYHZK0ujMTmnHbGBIS3cZcD7w1iTnAIcBBwJfraofzE1qzwc8D/g5cEhV/WL+N0ly2Aiv\n+VjzlDypqh4bOPb0IfPvax9fX1XXLuUFquoe4EzgzCQvoNnmdzpwBs25iKeMUK8kDTI7JWl0Zqc0\nhNfAkJaoXRCuBp4JHMf28xIvGZi6L7AHsGnIIrInMMotorbQvE/3G3LsZUPGvtk+jrJYbVNV36+q\n9cARNJ37457I95GkOWanJI3O7JSGs4EhjWZuy95ZwBuBu4ErBubcATwCvDzJU+cGkzwZuAhYNcLr\nbW4fF9wLvL0l1QmPn84VwI+BM5K8dtg3TPKqJH/Q/v3AJAcMmbYK2A14aIRaJWlHzE5JGp3ZKQ3w\nFBJpNDfQBPUr2q8vbm8LtU1VbU1yEfB+4NYkV9Ocd/iXwF40V4M+YomvdynNovWR9lZY3wUOAo6h\nWTSOH3jtR5K8CbgeuD7Jf9Pcm/th4HnAy2muFv0s4DfAIcAXk2xuv/cdwD7AG2jy4YIl1ilJizE7\nJWl0Zqc0wB0Y0giqqoAN84bW72DqOcDZNB3x02m2xH2LJsh/NsLr3Umz6FxPc47gu2i2CR7djg17\nzi3Ai2kujLQKeBvwTppF42bgZJotgrQ1XUBzzuOxNIvWa2k68MdU1YVLrVWSdsTslKTRmZ3S46V5\nX0iSJEmSJE0vd2BIkiRJkqSpZwNDkiRJkiRNPRsYkiRJkiRp6tnAkCRJkiRJU88GhiRJkiRJmno2\nMCRJkiRJ0tSzgSFJkiRJkqaeDQxJkiRJkjT1bGBIkiRJkqSp93vs4wiaAwr3QgAAAABJRU5ErkJg\ngg==\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x7f119a5ff150>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "import matplotlib.pyplot as plt \n",
    "% matplotlib inline\n",
    "\n",
    "sess = tf.InteractiveSession()\n",
    "\n",
    "# === Noramal and Truncated normal distributions ===\n",
    "mean = 0\n",
    "std = 1\n",
    "x_normal = tf.random_normal((1,50000),mean,std).eval()\n",
    "x_truncated = tf.truncated_normal((1,50000),mean,std).eval()\n",
    "\n",
    "# === Uniform distribution\n",
    "minval = -2 \n",
    "maxval = 2\n",
    "x_uniform = tf.random_uniform((1,50000),minval,maxval).eval()\n",
    "\n",
    "sess.close()\n",
    "\n",
    "\n",
    "def simpleaxis(ax):\n",
    "    ax.spines['top'].set_visible(False)\n",
    "    ax.spines['right'].set_visible(False)\n",
    "    ax.get_xaxis().tick_bottom()\n",
    "    ax.get_yaxis().tick_left()\n",
    "#     ax.set_ylim([-1.1,1.1])\n",
    "    ax.tick_params(axis='both', which='major', labelsize=15)\n",
    "    \n",
    "def get_axis_limits(ax, scale=.8):\n",
    "    return ax.get_xlim()[1]*scale, ax.get_ylim()[1]*scale\n",
    "\n",
    "f,axarr = plt.subplots(1,3,figsize=[15,4],sharey=True)\n",
    "titles = ['Normal','Truncated Normal','Uniform']\n",
    "\n",
    "print(x_normal.shape)\n",
    "for i,x in enumerate([x_normal,x_truncated,x_uniform]):\n",
    "    ax = axarr[i]\n",
    "    ax.hist(x[0],bins=100,color='b',alpha=0.4)\n",
    "    ax.set_title(titles[i],fontsize=20)\n",
    "    ax.set_xlabel('Values',fontsize=20)\n",
    "    ax.set_xlim([-5,5])\n",
    "    ax.set_ylim([0,1800])\n",
    "    \n",
    "    simpleaxis(ax)\n",
    "    \n",
    "    \n",
    "axarr[0].set_ylabel('Frequency',fontsize=20)\n",
    "plt.suptitle('Initialized values',fontsize=30, y=1.15)\n",
    "\n",
    "\n",
    "for ax,letter in zip(axarr,['A','B','C']):\n",
    "    simpleaxis(ax)\n",
    "    ax.annotate(letter, xy=get_axis_limits(ax),fontsize=35)\n",
    "\n",
    "plt.tight_layout()\n",
    "\n",
    "plt.savefig('histograms.png', bbox_inches='tight', format='png', dpi=200, pad_inches=0,transparent=True)\n",
    "\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The content of 'c':\n",
      " [ 0.  1.  2.  3.  4.]\n",
      "\n"
     ]
    }
   ],
   "source": [
    "sess = tf.InteractiveSession()\n",
    "c = tf.linspace(0.0, 4.0, 5) \n",
    "print(\"The content of 'c':\\n {}\\n\".format(c.eval()))\n",
    "sess.close()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Matrix multiplication"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "()\n",
      "(3,)\n",
      "(3, 1)\n",
      "matmul result:\n",
      " [[ 4]\n",
      " [10]]\n"
     ]
    }
   ],
   "source": [
    "A = tf.constant([ [1,2,3],\n",
    "                  [4,5,6] ])\n",
    "print(a.get_shape())\n",
    "\n",
    "x = tf.constant([1,0,1])\n",
    "print(x.get_shape())\n",
    "\n",
    "x = tf.expand_dims(x,1)\n",
    "print(x.get_shape())\n",
    "\n",
    "b = tf.matmul(A,x)\n",
    "\n",
    "sess = tf.InteractiveSession()\n",
    "print('matmul result:\\n {}'.format(b.eval()))\n",
    "sess.close()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Names  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "c:0\n",
      "c_1:0\n"
     ]
    }
   ],
   "source": [
    "with tf.Graph().as_default():\n",
    "    c1 = tf.constant(4,dtype=tf.float64,name='c') \n",
    "    c2 = tf.constant(4,dtype=tf.int32,name='c') \n",
    "print(c1.name)\n",
    "print(c2.name)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Name scopes"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "c:0\n",
      "prefix_name/c:0\n",
      "prefix_name/c_1:0\n"
     ]
    }
   ],
   "source": [
    "with tf.Graph().as_default():\n",
    "    c1 = tf.constant(4,dtype=tf.float64,name='c') \n",
    "    with tf.name_scope(\"prefix_name\"):\n",
    "        c2 = tf.constant(4,dtype=tf.int32,name='c') \n",
    "        c3 = tf.constant(4,dtype=tf.float64,name='c')\n",
    "\n",
    "print(c1.name)\n",
    "print(c2.name)\n",
    "print(c3.name)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Variables\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "pre run: \n",
      "<tf.Variable 'var:0' shape=(1, 5) dtype=float32_ref>\n",
      "\n",
      "post run: \n",
      "[[-0.69993478  1.55560553  0.55664998 -1.7586478   3.34199762]]\n"
     ]
    }
   ],
   "source": [
    "init_val = tf.random_normal((1,5),0,1)\n",
    "var = tf.Variable(init_val, name='var') \n",
    "print(\"pre run: \\n{}\".format(var))\n",
    "\n",
    "init = tf.global_variables_initializer()\n",
    "with tf.Session() as sess:\n",
    "    sess.run(init)\n",
    "    post_var = sess.run(var)\n",
    "\n",
    "print(\"\\npost run: \\n{}\".format(post_var))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### New variables are created each time"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "pre run: \n",
      "<tf.Variable 'var_1:0' shape=(1, 5) dtype=float32_ref>\n",
      "\n",
      "post run: \n",
      "[[-0.97382897 -0.38875952 -1.22835159 -0.75114495  0.50170541]]\n"
     ]
    }
   ],
   "source": [
    "init_val = tf.random_normal((1,5),0,1)\n",
    "var = tf.Variable(init_val, name='var') \n",
    "print(\"pre run: \\n{}\".format(var))\n",
    "\n",
    "init = tf.global_variables_initializer()\n",
    "with tf.Session() as sess:\n",
    "    sess.run(init)\n",
    "    post_var = sess.run(var)\n",
    "\n",
    "print(\"\\npost run: \\n{}\".format(post_var))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Placeholders"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "outs = 6.63996839523\n"
     ]
    }
   ],
   "source": [
    "x_data = np.random.randn(5,10) \n",
    "w_data = np.random.randn(10,1) \n",
    "\n",
    "with tf.Graph().as_default():\n",
    "    x = tf.placeholder(tf.float32,shape=(5,10))\n",
    "    w = tf.placeholder(tf.float32,shape=(10,1))\n",
    "    b = tf.fill((5,1),-1.) \n",
    "    xw = tf.matmul(x,w)\n",
    "\n",
    "    xwb = xw + b\n",
    "    s = tf.reduce_max(xwb)\n",
    "    with tf.Session() as sess:\n",
    "        outs = sess.run(s,feed_dict={x: x_data,w: w_data}) \n",
    "\n",
    "print(\"outs = {}\".format(outs))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Example 1: Linear Regression"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# === Create data and simulate results =====\n",
    "x_data = np.random.randn(2000,3)\n",
    "w_real = [0.3,0.5,0.1]\n",
    "b_real = -0.2\n",
    "\n",
    "noise = np.random.randn(1,2000)*0.1\n",
    "y_data = np.matmul(w_real,x_data.T) + b_real + noise"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(0, [array([[ 0.30298612,  0.48779276,  0.0716765 ]], dtype=float32), -0.18869072])\n",
      "(5, [array([[ 0.3005667 ,  0.50066561,  0.09561971]], dtype=float32), -0.19749904])\n",
      "(10, [array([[ 0.3005667 ,  0.50066561,  0.0956197 ]], dtype=float32), -0.19749907])\n"
     ]
    }
   ],
   "source": [
    "NUM_STEPS = 10\n",
    "\n",
    "g = tf.Graph()\n",
    "wb_ = []\n",
    "with g.as_default():\n",
    "    x = tf.placeholder(tf.float32,shape=[None,3])\n",
    "    y_true = tf.placeholder(tf.float32,shape=None)\n",
    "    \n",
    "    with tf.name_scope('inference') as scope:\n",
    "        w = tf.Variable([[0,0,0]],dtype=tf.float32,name='weights')\n",
    "        b = tf.Variable(0,dtype=tf.float32,name='bias')\n",
    "        y_pred = tf.matmul(w,tf.transpose(x)) + b\n",
    "\n",
    "    with tf.name_scope('loss') as scope:\n",
    "        loss = tf.reduce_mean(tf.square(y_true-y_pred))\n",
    "  \n",
    "    with tf.name_scope('train') as scope:\n",
    "        learning_rate = 0.5\n",
    "        optimizer = tf.train.GradientDescentOptimizer(learning_rate)\n",
    "        train = optimizer.minimize(loss)\n",
    "\n",
    "    # Before starting, initialize the variables.  We will 'run' this first.\n",
    "    init = tf.global_variables_initializer()\n",
    "    with tf.Session() as sess:\n",
    "        sess.run(init)      \n",
    "        for step in range(NUM_STEPS):\n",
    "            sess.run(train,{x: x_data, y_true: y_data})\n",
    "            if (step % 5 == 0):\n",
    "                print(step, sess.run([w,b])) \n",
    "                wb_.append(sess.run([w,b]))\n",
    "                \n",
    "        print(10, sess.run([w,b]))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Example 2: Logistic Regression\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "N = 20000\n",
    "\n",
    "def sigmoid(x):\n",
    "    return 1 / (1 + np.exp(-x))\n",
    "# === Create data and simulate results =====\n",
    "x_data = np.random.randn(N,3)\n",
    "w_real = [0.3,0.5,0.1]\n",
    "b_real = -0.2\n",
    "wxb = np.matmul(w_real,x_data.T) + b_real\n",
    "\n",
    "y_data_pre_noise = sigmoid(wxb)\n",
    "y_data = np.random.binomial(1,y_data_pre_noise)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(0, [array([[ 0.03320302,  0.05792972,  0.01119308]], dtype=float32), -0.020700064])\n",
      "(5, [array([[ 0.14649118,  0.2548342 ,  0.04982107]], dtype=float32), -0.091209568])\n",
      "(10, [array([[ 0.20652841,  0.35850295,  0.07069619]], dtype=float32), -0.12844093])\n",
      "(15, [array([[ 0.23972291,  0.41549107,  0.08243967]], dtype=float32), -0.14894117])\n",
      "(20, [array([[ 0.25859103,  0.44772011,  0.08921722]], dtype=float32), -0.16054493])\n",
      "(25, [array([[ 0.26949188,  0.4662571 ,  0.09318593]], dtype=float32), -0.16722204])\n",
      "(30, [array([[ 0.27584928,  0.47702512,  0.09552839]], dtype=float32), -0.17110163])\n",
      "(35, [array([[ 0.27957708,  0.48331678,  0.09691675]], dtype=float32), -0.17336872])\n",
      "(40, [array([[ 0.28176975,  0.48700568,  0.09774131]], dtype=float32), -0.17469805])\n",
      "(45, [array([[ 0.28306174,  0.48917308,  0.09823143]], dtype=float32), -0.17547914])\n",
      "(50, [array([[ 0.28370172,  0.49024412,  0.09847598]], dtype=float32), -0.17586514])\n"
     ]
    }
   ],
   "source": [
    "NUM_STEPS = 50\n",
    "\n",
    "\n",
    "g = tf.Graph()\n",
    "wb_ = []\n",
    "with g.as_default():\n",
    "    x = tf.placeholder(tf.float32,shape=[None,3])\n",
    "    y_true = tf.placeholder(tf.float32,shape=None)\n",
    "    \n",
    "    with tf.name_scope('inference') as scope:\n",
    "        w = tf.Variable([[0,0,0]],dtype=tf.float32,name='weights')\n",
    "        b = tf.Variable(0,dtype=tf.float32,name='bias')\n",
    "        y_pred = tf.matmul(w,tf.transpose(x)) + b\n",
    "\n",
    "    with tf.name_scope('loss') as scope:\n",
    "        loss = tf.nn.sigmoid_cross_entropy_with_logits(labels=y_true,logits=y_pred) \n",
    "        loss = tf.reduce_mean(loss)\n",
    "  \n",
    "    with tf.name_scope('train') as scope:\n",
    "        learning_rate = 0.5\n",
    "        optimizer = tf.train.GradientDescentOptimizer(learning_rate)\n",
    "        train = optimizer.minimize(loss)\n",
    "\n",
    "\n",
    "\n",
    "    # Before starting, initialize the variables.  We will 'run' this first.\n",
    "    init = tf.global_variables_initializer()\n",
    "    with tf.Session() as sess:\n",
    "        sess.run(init)      \n",
    "        for step in range(NUM_STEPS):\n",
    "            sess.run(train,{x: x_data, y_true: y_data})\n",
    "            if (step % 5 == 0):\n",
    "                print(step, sess.run([w,b]))\n",
    "                wb_.append(sess.run([w,b]))\n",
    "\n",
    "        print(50, sess.run([w,b]))"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "tf_1_0",
   "language": "python",
   "name": "tf_1_0"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2.0
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}